package test.netty.client;

import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;

/**
 * @author cuichao
 * @Description: ClientExceptionHandler
 * @Date: create in 2020/12/21 21:39
 */
public class ClientExceptionHandler extends ChannelDuplexHandler {


    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
        System.err.println("ClientExceptionHandler#encode");
        super.write(ctx, msg, promise);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        System.out.println("ClientInputExceptionHandler获取异常:"+cause);
/*        ctx.channel().close().addListeners(future -> {
            System.err.println(future.isSuccess());
        });*/
    }
}
